#!/bin/env sh 

cd /home/course

# Create backup with timestamp
timestamp=$(date +%Y%m%d_%H%M%S)
sudo tar vczf "DjangoBlog_${timestamp}.tar.gz" DjangoBlog

# Keep only the latest 3 backups
ls -t DjangoBlog_*.tar.gz | tail -n +4 | xargs -r rm --